<template>
  <div>
    <div class="f_30 f_bold">表格测试</div>
    <Card class="marginB10">
      <Table border :columns="columns" :data="tableData"></Table>
    </Card>
  </div>
</template>

<script>
export default {
  name: "applyBill",
  components: {},
  data() {
    let data = {
      columns: [
        {
          title: "Name",
          key: "name"
        },
        {
          title: "Age",
          key: "age",
          render: (h, params) => {
            // xxxx
          }
        },
        {
          title: "Action",
          key: "action",
          render: (h, params) => {
            return h("div", [
              h(
                "div",
                {
                  style: {
                    paddingLeft: "20px",
                    "margin-bottom": "10px"
                  },
                  class: "f_24"
                },
                "无敌最寂寞"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.show(params.index);
                    }
                  }
                },
                "详情"
              ),

              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small"
                  },
                  on: {
                    click: () => {
                      this.remove(params.index);
                    }
                  }
                },
                "删除"
              )
            ]);
          }
        }
      ],

      tableData: [
        {
          name: "John Brown",
          age: 18,
          address: "New York No. 1 Lake Park",
          province: "America",
          city: "New York",
          zip: 100000
        },
        {
          name: "Jim Green",
          age: 24,
          address: "Washington, D.C. No. 1 Lake Park",
          province: "America",
          city: "Washington, D.C.",
          zip: 100000
        },
        {
          name: "Joe Black",
          age: 30,
          address: "Sydney No. 1 Lake Park",
          province: "Australian",
          city: "Sydney",
          zip: 100000
        },
        {
          name: "Jon Snow",
          age: 26,
          address: "Ottawa No. 2 Lake Park",
          province: "Canada",
          city: "Ottawa",
          zip: 100000
        }
      ]
    };
    return data;
  },
  mounted() {
    //
  },
  methods: {
    show(index) {
      this.$Modal.info({
        title: "触发",
        content: `这个是第${index}行信息`
      });
    },
    remove(index) {
      this.tableData.splice(index, 1);
    }
  }
};
</script>

